/*
 * Copyright 2025 author or author.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jcwang.commons.tools.util.net;

import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serial;
import java.util.regex.Pattern;

/**
 * 系统正则
 *
 * @author 王金城
 **/
public class OSRegex implements java.io.Serializable {

    @Serial
    private static final long serialVersionUID = 6755702089913079847L;
    /**
     * 系统名称
     **/
    private String name;
    /**
     * 系统正则
     **/
    private String regex;
    /**
     * 系统正则Pattern对象
     **/
    private Pattern pattern;

    public OSRegex() {
    }

    public OSRegex(String name, String regex) {
        this.name = name;
        this.regex = regex;
        this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRegex() {
        return regex;
    }

    public void setRegex(String regex) {
        this.regex = regex;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("name", name)
                .append("regex", regex)
                .append("pattern", pattern)
                .toString();
    }
}
